package com.lovo.manage_back.controller;

import com.lovo.manage_back.bean.Authority;
import com.lovo.manage_back.bean.form.AuthorityForm;
import com.lovo.manage_back.result.GlobalHandleException;
import com.lovo.manage_back.result.ResponseResult;
import com.lovo.manage_back.service.AuthorityService;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/authorities")
@ResponseResult
@Tag(name = "权限管理AuthorityController")
@SecurityRequirement(name = "bearer-key")
public class AuthorityController {
    @Autowired
    private AuthorityService authorityService;
    @PostMapping
    public Object addAuthority(@RequestBody AuthorityForm authorityForm) throws GlobalHandleException {
        Authority authority = new Authority();
        BeanUtils.copyProperties(authorityForm,authority);
        return authorityService.add(authority);

    }
}
